package com.common.android.ui.LocalAlbum;

import android.os.Parcel;
import android.os.Parcelable;

public class FileInfo implements Parcelable {

	public long mLastModified; // 目录或文件的最后更新时间
	public String mFilePathOrName; // 文件全路径
	public long mID;				// images表中的_id
	
	private static final long DEFAULT_ID = -2424;		//由图片路径构造的时候，无法得到ID,给一个默认ID

	public FileInfo() {
		mID = DEFAULT_ID;
		mFilePathOrName = "";
	}
	
	public long getDefaultID(){
		return DEFAULT_ID;
	}
	
	private FileInfo(Parcel in) {
		mLastModified = in.readLong();
		mFilePathOrName = in.readString();
		mID = in.readLong();
	}

	public int lastModifiedCmp(FileInfo fi) {
		if (mLastModified == fi.mLastModified) {
			return 0;
		} else if (mLastModified > fi.mLastModified) {
			return -1;
		} else {
			return 1;
		}
	}

	@Override
	public int describeContents() {
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeLong(mLastModified);
		dest.writeString(mFilePathOrName);
		dest.writeLong(mID);
	}

	public static final Parcelable.Creator<FileInfo> CREATOR = new Parcelable.Creator<FileInfo>() {

		@Override
		public FileInfo createFromParcel(Parcel in) {
			return new FileInfo(in);
		}

		@Override
		public FileInfo[] newArray(int size) {
			return new FileInfo[size];
		}

	};

}
